package geographer;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Project #3
 * CS 2334, 010
 * 03/26/2014
 * <P>
 * This class represents the continent class. It inherits from DemographicRegion and implements Serializable.
 * </P>
 * @version 3.0
 */
public class Continent extends GeographicRegion implements Serializable {
	
	/**
	 * The serial ID for this continent.
	 */
	private static final long serialVersionUID = 1L;
	
	/*The List of countries within the continent*/
	private List<String> countries;
	
	
	/**
	 * Continent constructor
	 * <P>
	 * Creates a new continent object
	 * </P>
	 * @param	data	Data to be passed into the constructor
	 */
	public Continent(String... data) {
		super(data[0], data[1], data[2]); //send data array to the super constructor
		countries = new ArrayList<String>();//create countries ArrayList
	}//end constructor
	
	public void edit(String[] data)
	{
		super.edit(data[0], data[1], data[2]);
		countries = new ArrayList<String>();
		this.add(data[3]);
	}
	
	/**
	 * Adds country to continent
	 * <P>
	 * Algorithm:<br>
	 * 1. Add country to the ArrayList<br>
	 * </P>
	 * @param	country	Country to add to the continent
	 * @return	boolean	Success of the operation
	 * <dt><b>Conditions:</b>
	 * <dd>PRE -   <code>country</code> must be a non - null value
	 * <dd>POST  -   The specified <code>Country</code> object was added to the array
	 */
	public boolean add(String country){
		return countries.add(country);
	}//end add
	
	/**
	 * Gets subregions of the continent
	 * <P>
	 * Algorithm:<br>
	 * 1. Return the subregions of the continent<br>
	 * </P>
	 * @return	countries	Countries list of subregions
	 * <dt><b>Conditions:</b>
	 * <dd>POST  -   The correct subregions were returned
	 */
	public List<String> getSubregions(){
		return countries;
	}//end getSubregions

	/**
	 * Returns the contents of the <code>Continent</code> object as a string.
	 * <P>
	 * Algorithm:<br>
	 * 1. Create a string containing all values within this object <br>
	 * 2. Return the string<br>
	 * </P>
	 *@return   String A string containing all information in the <code>Continent</code> object.
	 * <dt><b>Conditions:</b>
	 * <dd>POST -          A String continaing all information for this object is returned.
	 */
	@Override
	public String toString() {
		return  this.getName() +", "+ 
				this.getArea() +", "+ 
				this.getPopulation();
	}//end toString
}//end Continent
